﻿///
/// \brief 各类播放引擎的基类 
///
#ifndef PLAYERBASE_H
#define PLAYERBASE_H

#include <QObject>
#include <QString>
#include <QWidget>

///
/// \brief The PlayerBase class 接口参照QMediaPlayer封装
///
class PlayerBase : public QObject
{
    Q_OBJECT
public:
    PlayerBase(QObject *parent = nullptr);
    virtual ~PlayerBase();
    
    virtual bool open(const QString& media)     = 0;//打开文件
    virtual bool play()     = 0;//播放
    virtual bool pause()    = 0;//暂停
    virtual bool stop()     = 0;//停止

//    virtual QP::PlaybackState state() const = 0;//播放状态
//    virtual void setState(QP::PlaybackState state) = 0; //设置播放状态
    
    virtual float volume() const = 0;//音量
    virtual void setVolume(float volume) = 0;           //设置音量
    
    virtual bool isMuted() const = 0;//是否静音
    virtual void setMuted(bool muted) = 0;              //设置静音

    virtual void setPlaybackRate(float rate) = 0;//播放速率 0.5/0.75/1.0/1.5/2.0......
    
    virtual void setVideoWidget(QObject* w) = 0;
    
signals:
    void MediaPlay();
    void MediaPause();
    void MediaStop();
    void MediaNext();
    void MediaPrevious();
    void changeVolume(float volume);
    void changeMuting(bool muting);
    void changeRate(qreal rate);
    
protected:
    QString media;
    
};


#endif // PLAYERBASE_H
